package com.translate.web.api.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.response.vo.ResponseModel;
import com.controller.base.AbstractCommonController;
import com.translate.entity.ProductImg;
import com.jwt.IJwtUtil;
import com.translate.web.param.ProductSearchParam;
import com.param.impl.IdParam;
import com.translate.web.service.IProductImgService;
import com.basic.service.contract.IBaseService;

@RestController
@RequestMapping("productImage")
public class ProductImageController extends AbstractCommonController<ProductImg, ProductSearchParam> {
	
	private IProductImgService imgService;
	
	
	private IJwtUtil jwtUtil;

	public ProductImageController(IProductImgService imgService) {
		this.imgService = imgService;
	}

	@Override
	protected IBaseService<ProductImg> getBaseService() {
		return this.imgService;
	}

	protected <VO> Class<VO> getTarget() {
		return (Class<VO>) ProductImg.class;
	}
	
	@PostMapping("getProductImageList")
	public ResponseModel<List<ProductImg>> getProductImageList(@Validated @RequestBody IdParam param) {
		
		return ResponseModel.<List<ProductImg>>success(this.imgService.getProductImgs(param));
	}

	protected long getUserId(HttpServletRequest httpServletRequest) {
		return jwtUtil.getId(httpServletRequest.getHeader(jwtUtil.getJwtConfig().getHeader()));
	}

}